package com.caiden_micheal.position.mapper;

import com.caiden_micheal.position.domain.Position;
import com.caiden_micheal.position.vo.PositionQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PositionMapper {
    List<Position> findPositionListPaginationQuery(@Param("positionQueryVO") PositionQueryVO positionQueryVO, @Param("positionIdList") List<Long> positionIdList);

    Integer findPositionListQueryCount(@Param("positionQueryVO") PositionQueryVO positionQueryVO, @Param("positionIdList") List<Long> positionIdList);

    void addPosition(@Param("position") Position position);

    void updatePosition(@Param("position") Position position);

    @Select("SELECT * FROM sys_position WHERE id=#{positionId}")
    Position findById(@Param("positionId") Long positionId);

    @Select("SELECT * FROM sys_position WHERE position_name=#{positionName}")
    Position findByName(@Param("positionName") String positionName);

    @Delete("DELETE FROM sys_position WHERE id=#{position.id}")
    void remove(@Param("position") Position position);

    List<Position> findByIds(@Param("positionIds") List<Long> positionIds);

    List<Position> findPositionListPaginationQueryExcludeAuthority(@Param("positionQueryVO") PositionQueryVO positionQueryVO, @Param("positionIdList") List<Long> positionIdList);

    Integer findPositionListQueryCountExcludeAuthority(@Param("positionQueryVO") PositionQueryVO positionQueryVO, @Param("positionIdList") List<Long> positionIdList);

    @Select("SELECT * FROM sys_position WHERE `rank`=#{rank}")
    Position findByRank(@Param("rank") Integer rank);
}